<?php
namespace Action;
class Index extends Daniuwo {
	public function Index(){
		$this->v('title',$this->conf['wwwname']);
		$this->v('info',$this->conf['wwwinfo']);
		$this->v('tongji',$this->conf['tongji']);
		$this->display('index');
	}
	// 登录
	public function login(){
		$this->v('title','管理员登录');
		if(IS_LOGIN){
			return $this->message("你都已经登录了,登录那么多次干嘛");
		}

		if(IS_POST){
			$user = X('post.user');
			$pass = X('post.pass');
			$UserLib = L("User");
			if(!$UserLib->check_pass($pass))
				return $this->message('密码不符合规则');
	
			$User = M("User");
	
			if(!$User->is_user($user))
				return $this->message("账号不存在!");

			$data = $User->user_read($user);
			if(!empty($data)){
                //密码正确
                if($data['pass'] == $UserLib->md5_md5($pass,$data['salt'])){//登录成功

                    //在线用户结束
                    cookie('HYBBS_HEX',$UserLib->set_cookie($data));
                    $this->init_user();
                    //{hook a_user_login_54}
                    $re_url = cookie('re_url');
                    if($re_url=='')
                        $re_url='';
                    cookie('re_url',null);
                    return $this->message("登录成功 !",true,$re_url);
                }else{
                    //{hook a_user_login_56}
                    return $this->message("密码错误!");
                }
            }else{
                return $this->message('账号数据不存在!');
            }
		}
		$this->display('login');
	}

}